package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetMealMapper {
    @AutoFill(OperationType.INSERT)
    @Insert("insert into setmeal (category_id,name,price,status,description,image,create_time,update_time,create_user,update_user) " + "values (#{categoryId},#{name},#{price},#{status},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser}) ")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insert(Setmeal setmeal);

    Page<Setmeal> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    @Select("select * from setmeal where id=#{id}")
    Setmeal selectById(Long id);

    @AutoFill(OperationType.UPDATE)
    @Update("update setmeal set category_id=#{categoryId},name=#{name},price=#{price},status=#{status},description=#{description},image=#{image},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void update(Setmeal setmeal);

    @Delete("delete  from setmeal where id=#{id}")
    void deleteById(Long id);

    @Select("select * from setmeal where category_id=#{id}")
    List<Setmeal> list(Long categoryId);
    Integer countByMap(Map map);

}
